package com.crowdfunding.controller;


import com.crowdfunding.entity.CrowdfundingImage;
import com.crowdfunding.service.ICrowdfundingImageService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author xiaoyu
 * @since 2021-07-19
 */
@RestController
@RequestMapping("/crowdfunding/crowdfundingImage")
public class CrowdfundingImageController {
    @Autowired
    ICrowdfundingImageService imageService;


    @GetMapping("/getListByCfId")
    @ResponseBody
    @ApiOperation("通过活动id查找图片")
    public List<CrowdfundingImage> getImageByCfId(String cfId){

        return imageService.getImageListByCfId(cfId);
    }

    @DeleteMapping("deleteImageById")
    @ResponseBody
    public ResponseEntity deleteImageById(int imgId){
        try {
            imageService.deleteImageById(imgId);
            return ResponseEntity.status(500).body("删除成功");
        }
        catch (Exception e){
            e.printStackTrace();
            return ResponseEntity.status(500).body(e.getMessage());
        }

    }


}

